<?php

/**
 * MyAccountEditForm
 *
 * @author fusq
 */
require_once   BaseUtil::getModulePath("base")  .  '/validate/Unique.php';
require_once BaseUtil::getModulePath("base")  .  '/forms/BaseForm.php';

class MyAccountEditForm extends BaseForm {

    public function __construct ($admin = array()){
        parent::__construct();
        $this->setAction(HttpUtil::getUrl("admin", "subeditinfo"));

        //id
        $id = new Zend_Form_Element_Hidden('adminId');
        $id->setValue($admin['id']);
        $this->addElement($id);
        // username
        $name = new Zend_Form_Element_Text('name');
        $name->setLabel($this->translate->_('userName'));
        $name->addFilter("StringTrim");
        $name->setRequired(true);
        $name->setValue($admin['username']);
        // passwrod
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel($this->translate->_('password'));
        $password->addFilter("StringTrim");
        //email
        $validUnique = new MyValid_Unique();
        $validUnique -> setFetchAttr("admins", "email", $admin['id']);
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel($this->translate->_('userEmail'));
        $email->addFilter("StringTrim");
        $email->setRequired(true);
        $email->addValidator('EmailAddress');
        $email->addValidator($validUnique);
        $email->setValue($admin['email']);

        $this->addElements(array($id,$name,$password,$email));

        $this->setElementDecorators(array(
            'ViewHelper',
            array(array('div' => 'HtmlTag'), array('tag' => 'div',"class" => "form_element")),
        ));
    }
    
}